Skip to content

✨ Improved URL API and new CLI - #1076

Merged
mrkai77 merged 20 commits into
developfrom
kai/improved-api
Nov 23, 2026
Merged

mrkai77 merged 20 commits into
developfrom
kai/improved-api

Conversation

@mrkai77

@mrkai77 mrkai77 commented Apr 4, 2026 •

Copy link
Copy Markdown
Owner

This PR adds a loop command that can be installed from Advanced settings, and reworks the URL scheme so both run the same commands. Unlike opening a URL, the command returns results, so scripts can list windows, actions and keybinds, and tell whether a command worked. Targets are spelled like actions will be in the upcoming settings file, so scripts written now keep working once it lands. This PR:

  1. Adds loop run <target> and loop list actions|keybinds|gestures|radial-menu|windows|screens, with matching loop://run/… and loop://list/… URLs. A target is a built-in action like right-half, or one of your own as keybind:<id>, gesture:<id> or radial-menu:<id>, with IDs derived from names,
  2. Runs actions on the same window and screen a keybind would, refuses excluded apps and ignored full-screen windows, and advances cycles. --window-id, --bundle-id and --screen-id pick something else, and only the CLI opens apps that aren't running,
  3. Prints aligned tables in a terminal and tab-separated lines when piped. --json prints a versioned response with stable error codes, and exit codes tell apart a failed command, bad usage, Loop not running and a timeout,
  4. Installs /usr/local/bin/loop through the privileged helper (renamed from LoopUpdaterHelper, as it's no longer just for updates), which now checks the signatures of both Loop and loop-cli and replaces the link without following symlinks. Loop only answers the CLI once it's been installed,
  5. Keeps older URLs like loop://direction/right and loop://keybind/<name> working,
  6. Stops a loop:// URL from showing the Dock icon or opening Settings. macOS gives Loop a Dock icon before handing it a URL since Loop isn't an LSUIElement app, so Loop now hides it again, and only opens Settings when launched from Finder, the Dock or open

@mrkai77 mrkai77 self-assigned this Apr 4, 2026
@mrkai77
mrkai77 force-pushed the kai/improved-api branch from a8273e1 to 576b7d1 Compare April 4, 2026 20:28
@mrkai77 mrkai77 added the Feature label Apr 4, 2026
@mrkai77 mrkai77 linked an issue Apr 4, 2026 that may be closed by this pull request
4 of 6 tasks
@mrkai77
mrkai77 marked this pull request as ready for review October 9, 2026 05:35
- Talk to Loop over a per-user Unix socket, with JSON shared between the CLI and the app
- Install and uninstall the loop symlink from Advanced settings through the privileged helper
- Remove the old URL command code it replaces
- Share routes, models, JSON and formatting between the CLI and the app
- Show list results in a Loop output window, and failures in an alert
- Fix reopening Settings, a crash with a missing screen, and the alert after canceling authorization
- Start the socket after older instances exit, and only remove the socket file this instance bound
- Time out sends as well as reads, and explain timeouts and oversized requests
- Share LoopSocketManager like the other managers, with start() and shutdown()
- Log requests once, and responses at debug level
- loop run <target> takes a built-in action like right-half, or key:, gesture: and radial-menu: ids derived like the upcoming settings file's
- loop list actions|keys|gestures|radial-menu|windows|screens, and the same routes as loop:// URLs
- Target windows and screens like keybinds do, refuse excluded apps and ignored full-screen windows, and advance cycles
- Version the JSON, keep every key present, and give errors a stable code and the CLI sysexits exit codes
- Keep URLs from earlier versions working, with tests
- Document the new commands
- Check the client's signature on every message, and trust the bundle path of the code that passed the check
- Only link a loop-cli signed by Loop's developer, and replace the link through the opened /usr/local/bin folder
- Offer the Applications folder again when the password prompt is canceled, without catching unrelated cancellations
- Localize the helper coordinator's errors
- Use the same wording for the command-line tool's states in settings and the CLI
- Move PrivilegedHelperCoordinator to Utilities, as the updater and the CLI installer share it
- Align lists in columns under a header, with what to pass to run in the first column, and fit them to the terminal's width
- Print tab-separated lines without a header when piped, so cut and awk can read them
- Dim inactive bindings, mark successful runs with a green check, and color "Error:" red
- Honor CLICOLOR_FORCE, and check stderr separately for colored errors
- Use the same tables in Loop's output window
- Run a cycle's next action on the new screen after a screen switching one, like keybinds do
- Reject a screen ID for screen switching actions, and a query parameter without a value
- Report moving to a desktop that doesn't exist as a failure
- Keep the old direction/custom… and action/<name> URLs matching what they did before
- List every desktop action, not only as many as there are right now
- Read the request before refusing it, so the CLI shows why instead of a write error
- Treat a response that isn't valid JSON as Loop being unavailable, and reject an empty --bundle-id
- Check the command-line tool's status again when Loop becomes active, and keep tabs from misaligning tables
- Only open Settings for a launch from Finder, the Dock or open, which has an open-application event that a URL launch doesn't
- Hide the Dock icon macOS adds before handing Loop a URL, unless Settings is open or the Dock icon is turned on
- Replace the deferred Settings open, which depended on the URL arriving within one run loop turn
- Give the helper's command-line tool errors one shared path
- Keep the CLI's English install reasons next to the settings warnings for the same statuses
- Let the action picker list every desktop instead of rebuilding its section
- Show the same key symbols in the CLI as in the Keybinds tab
- Share errno text and the loop-cli bundle layout
- List Loop’s own windows too, as they can be targeted like any other
- Encode nil as null with @NullEncoded instead of hand-written encoders
- Make LoopTarget a command-line argument directly, and build CLI invocations from route components
- Split the shared files so each holds one type and what belongs to it
- Use parameterized tests
…ndle+Extensions

- Follow the "Always start from the first action" setting for cycles, as each run is its own session like a separate keybind press
- Refuse to run without Accessibility access, like keybinds
- Move Bundle+Extensions to Shared, so the CLI reads its version with it
🔥 Derive default radial menu IDs from their names, like keybinds
@mrkai77
mrkai77 merged commit 0ad44cb into develop Nov 23, 2026
1 check passed
@mrkai77
mrkai77 deleted the kai/improved-api branch November 23, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 Calling the URL scheme causes the Loop icon to appear in the Dock

1 participant